package com.rich.group.controller;

import com.rich.common.result.CommonResponse;
import com.rich.group.pojo.GroupJoin;
import com.rich.group.service.GroupJoinService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author minicoco
 * @version 1.0
 * @date 2021/8/16 11:51
 */
@RestController
@RequestMapping("/group/join")
public class GroupJoinController {

    @Autowired
    private GroupJoinService groupJoinService;

    /**
     *  报名参团
     */
    @PutMapping("/signup/{uid}/{groupId}")
    public CommonResponse signup(@PathVariable("uid") Long uid ,
                                 @PathVariable("groupId") Long groupId){
        //TODO 用户id 应是登录用户的id
        return groupJoinService.signup(uid,groupId);
    }

    /**
     * 删除记录
     */
    @DeleteMapping("/deleteById/{id}")
    public void deleteById(@PathVariable("id") Long id){
        groupJoinService.deleteById(id);
    }

    /**
     * 查询单条
     * @return
     */
    @GetMapping("/findOneById/{id}")
    public GroupJoin findOneById(@PathVariable("id") Long id){
        return groupJoinService.findOneById(id);
    }

}
